﻿using SilentVoice.ServiceObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SilentVoice.Business;
using SilentVoice.Models;

namespace SilentVoice.Service.Controllers
{
    [Authorize]
    public class UsersController : ApiController
    {
        private Manager manager;

        public UsersController()
        {
            manager = new Manager();
        }

        // GET api/users
        public IEnumerable<string> Get()
        {
            throw new NotImplementedException();
        }

        // GET api/users/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/users
        public void Post([FromBody]string value)
        {
        }

        // PUT api/users/5
        public ServiceUser Put(int id, ServiceUser user)
        {
            user.User.Id = id;
            //TODO: this is funky...also, all backbone objects must have id
            return new ServiceUser(manager.UpdateUser(user.User));
        }

        // DELETE api/users/5
        public ServiceUser Delete(int id)
        {
            return new ServiceUser(manager.DeleteUser(new User() { Id = id }));
        }
    }
}
